mod csv;

pub use csv::CsvOpts;
pub use csv::OutputFormat;


mod genpass;

pub use genpass::GenPassOpts;


mod base64;


pub use base64::Base64Subcommand;
pub use base64::Base64Format;

mod text;
mod http;

pub use http::HttpSubcommand;
pub use http::HttpServeOpts;

pub use text::{TextSubcommand, TextSignFormat, TextSignOpts};

fn verify_input_file(filename: &str) -> Result<String, &'static str> {
    // if input is "-" of file exists
    if filename == "-" || std::path::Path::new(filename).exists() {
        Ok(filename.into())
    } else {
        Err("file does not exist")
    }
}

//测试代码
#[cfg(test)]
mod tests {
    use super::verify_input_file;

    #[test]
    fn test_verify_input_file() {
        assert_eq!(verify_input_file("-"), Ok("-".into()));
        assert_eq!(verify_input_file("Cargo.toml"), Ok("Cargo.toml".into()));
        assert_eq!(verify_input_file("xx.toml"), Err("file does not exist"));
    }
}